//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#include "engine.h"

static IGfxEngine * s_pGfxEngine = NULL;

extern "C" ECode GrafixEngine_Initialize()
{
    ECode ec = NOERROR;
    CGfxEngine * pGfxEngine = NULL;

    pGfxEngine = new CGfxEngine();
    if (NULL == pGfxEngine) {
        ec = E_OUT_OF_MEMORY;
        goto E_FAIL_EXIT;
    }

    ec = pGfxEngine->constructor();
    if (FAILED(ec)) {
        goto E_FAIL_EXIT;
    }
    pGfxEngine->AddRef();

    s_pGfxEngine = pGfxEngine;

    return NOERROR;

E_FAIL_EXIT:
    if (NULL != pGfxEngine) {
        delete pGfxEngine;
    }
    return ec;
}


extern "C" void GrafixEngine_Destroy()
{
    if (NULL != s_pGfxEngine) {
        s_pGfxEngine->Release();
        s_pGfxEngine = NULL;
    }
}

extern "C"  IGfxEngine * GetGfxEngineService()
{
    assert(NULL != s_pGfxEngine);
    return s_pGfxEngine;
}

